﻿using System.Text;

namespace net8.Helper
{
    /// <summary>
    /// 文件帮助类
    /// </summary>
    public class FileHelper
    {
        static object Lock = new object();
        public static void HttpLog(string content)
        {
            lock (Lock)
            {
                string date = DateTime.Now.ToString("yyyyMMdd");
                string root = AppContext.BaseDirectory + "HttpLog\\" + date + "\\";
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                string path = root + DateTime.Today.Hour + ".txt";
                File.AppendAllText(path, "当前时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff") + "\r\n", Encoding.UTF8);
                File.AppendAllText(path, content + "\r\n", Encoding.UTF8);
            }
        }

    }
}
